/*
 * Created on 22/Abr/2004
 *
 * To change the template for this generated file go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
package org.cyborgas.swt;

import java.net.URI;

import org.eclipse.jface.action.Action;

/**
 * @author rino
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MRUAction extends Action {
	
	private RecentFileList mru;
	private int position;

	public MRUAction(RecentFileList mru, int position) {
		super.setId(RecentFileList.MRU_MENU_MARKER + "_" + position);
		this.mru = mru;
		this.position = position;
		update();
	}
	
//	public int getPosition() {
//		return this.position;
//	}
//
//	public void setPosition(int position) {
//		this.position = position;
//	}
	
	
	public boolean update() {
		boolean isVisible;
		if (this.position < this.mru.size()) {
			URI url = mru.get(position);
			setText("&" + (position + 1) + " " + url.toString());
			setToolTipText(url.toString());
			isVisible = true;
		} else {
			setText((position + 1) + "");
			isVisible = false;
		}
		return isVisible;
	}

	public void run() {
		this.mru.itemSelected(this.position);
	}	


}
